<template>
<div>
  <h3>复试录入</h3>

  <el-card class="box-card">
    <el-row :gutter="20">
      <el-col :span="7">
        <el-input placeholder="请输入内容"
                  v-model="quertInfo.searchText" clearable
                  @clear="getsecondgradelist">
          <el-button slot="append" icon="el-icon-search"
                     @click="getsecondgradelist">
          </el-button>
        </el-input>
      </el-col>
      <el-col :span="4">
        <el-button type="primary" @click="addDialogVisable = true">添加学生</el-button>
      </el-col>
    </el-row>

    <el-table :data = secondgradeList>
      <el-table-column type="index" label="序号"></el-table-column>
      <el-table-column label="考号" prop="ENo"></el-table-column>
      <el-table-column label="专业课成绩" prop="SProfessionalGrade"></el-table-column>
      <el-table-column label="面试成绩" prop="InterviewGrade"></el-table-column>
      <el-table-column label="上机成绩" prop="PracticeGrade"></el-table-column>
      <el-table-column label="总成绩" prop="Count"></el-table-column>
      <el-table-column label="操作" width="200px">
        <!--修改按钮-->
        <template slot-scope="scope">
          <el-button type="primary" icon="el-icon-edit" size="mini"
          >修改</el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-card>


  <el-dialog
    title="添加学生"
    :visible.sync="addDialogVisable"
    width="50%" @close="addDialogClosed">
    <el-form :model="addForm"  ref="addFormRed" label-width="100px" >
      <el-form-item label="考号" prop="ENo">
        <el-input v-model="addForm.ENo"></el-input>
      </el-form-item>

      <el-form-item label="专业成绩" prop="SProfessionalGrade">
        <el-input v-model="addForm.SProfessionalGrade"></el-input>
      </el-form-item>

      <el-form-item label="面试成绩" prop="InterviewGrade">
        <el-input v-model="addForm.InterviewGrade"></el-input>
      </el-form-item>

      <el-form-item label="上机成绩" prop="PracticeGrade">
        <el-input v-model="addForm.PracticeGrade"></el-input>
      </el-form-item>

    </el-form>
    <span slot="footer" class="dialog-footer">
    <el-button @click="addDialogVisable = false">取 消</el-button>
    <el-button type="primary" @click="addsecondgrade">确 定</el-button>
  </span>
  </el-dialog>

</div>
</template>

<script>
export default {
  data() {
    return {
      quertInfo: {
        searchText: '',
        page: 1,
        //当前每页显示多少条数据
        limit: 50
      },
      secondgradeList: [],
      total: 0,
      addDialogVisable:false,

      addForm:{
        ENo: '',
        SProfessionalGrade: '',
        InterviewGrade: '',
        PracticeGrade: '',
        Count: ''
      },
      editdialogVisible: false,
      editForm: {

      }
    }
  },

  created() {
    this.getsecondgradelist()
  },

  methods: {
    addDialogClosed() {
      this.$refs.addFormRed.resetFields()
    },
    addsecondgrade() {
      this.$http.post('secondgrade', this.addForm)
      this.$message.success('添加成功')
      this.addDialogVisable = false
      this.getsecondgradelist()
    },

    async getsecondgradelist() {
      const {data: res} = await this.$http.get('secondgrade', {params: this.quertInfo})
      this.total = res.data.total
      this.secondgradeList = res.data.value
      console.log(res)
    },
  }
}
</script>

<style scoped>

</style>

